<template>
  <!-- 文章列表项组件 -->
  <!-- :to="'/article/'+article.art_id"-->
  <!-- :to="{根据路由名称进行跳转 -->
  <!-- name:'article', -->
  <!-- 传递路由动态参数 -->
  <!-- params:{属性名：路由路径中设计参数的动态参数名称 -->
  <!-- articleId:article.art_id -->
  <!-- } -->

  <van-cell class="article-item" :to="`/article/${article.art_id}`">
    <!-- 标题 -->
    <!-- vant里面的内置样式添加class设置最多显示两行 -->
    <div slot="title" class="van-multi-ellipsis--l2">{{ article.title }}</div>
    <!-- 标题下的内容 -->
    <div slot="label">
      <!-- 三张图片放这里 -->
      <div v-if="article.cover.type == 3" class="cover-wrap">
        <div
          class="cover-item"
          v-for="(img, index) in article.cover.images"
          :key="index"
        >
          <!-- 去掉 width="100" height="100" 加fit="cover" 让图片铺满 不遮挡字体 -->
          <van-image class="cover-item-img" fit="cover" :src="img" />
        </div>
      </div>
      <div class="label-info-wrap">
        <span>{{ article.aut_name }}</span>
        <span>{{ article.comm_count }}</span>
        <!-- 使用时间处理的过滤器 relativeTime -->
        <span>{{ article.pubdate | relativeTime }}</span>
      </div>
    </div>
    <!-- 右边的图片  一张图片的时候-->
    <div slot="default" v-if="article.cover.type == 1" class="right-cover">
      <van-image width="100" height="100" :src="article.cover.images[0]" />
    </div>
  </van-cell>
</template>

<script>
export default {
  name: 'ArticleItem',
  components: {},
  props: {
    // 接收父组件传过来的数据
    article: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {}
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {},
}
</script>

<style lang="less" scoped>
.article-item {
  .title {
    font-size: 32px;
    color: #3a3a3a;
  }

  .van-cell__title {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  .van-cell__value {
    flex: unset;
    width: 232px;
    height: 146px;
    padding-left: 25px;
  }

  .right-cover {
    width: 100%;
    height: 146px;
  }

  .label-info-wrap span {
    font-size: 22px;
    color: #b4b4b4;
    margin-right: 25px;
  }

  .cover-wrap {
    display: flex;
    padding: 30px 0;
    .cover-item {
      flex: 1;
      height: 146px;
      &:not(:last-child) {
        padding-right: 4px;
      }
      .cover-item-img {
        width: 100%;
        height: 146px;
      }
    }
  }
}
</style>
